<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Layout_module extends MY_Module {

	public function __construct() {
		parent::__construct();
		$this->load->model('layout_m');
	}

	public function admin($config) {
		$layouts = $this->layout_m->get_many_by('layout_id !=', $config['layout_id']);
		$config['config']['layout'] = array();
		$config['config']['area'] = array();
		$config['config']['area']['header'] = 'header';
		$config['config']['area']['footer'] = 'footer';
		if($layouts)
		{
			foreach($layouts as $layout)
			{
				$config['config']['layout'][$layout->layout_id] = $layout->layout_name; 
			}
		}
		
		$this->view('admin', $config['config']);
	}

	public function run($config) {
		if(!isset($config['layout'])) $config['layout'] = '';
		$this->view('index', $config);
	}
}